package com.golddaymicromall.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.golddaymicromall.activity.R;
import com.golddaymicromall.bean.LogisticInfo;

import java.util.List;

/**
 * Created by Administrator on 2016/5/11 0011.
 */
public class LogisticAdapter extends BaseAdapter {
    LayoutInflater layoutinflater;
    private List<LogisticInfo> list;
    private Context ctx;

    public LogisticAdapter(List<LogisticInfo> list, Context ctx) {
        this.list = list;
        this.ctx = ctx;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        View view = convertView;
        if (view == null) {
            holder = new ViewHolder();
            layoutinflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = layoutinflater.inflate(R.layout.item_logistic, null);
            holder.mLogistic_time = (TextView) view.findViewById(R.id.logistic_time);
            holder.mLogistic_process = (TextView) view.findViewById(R.id.logistic_process);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        holder.mLogistic_time.setText(list.get(position).getUpload_time());
        holder.mLogistic_process.setText(list.get(position).getProcessinfo());

        return view;
    }

    public class ViewHolder {
        TextView mLogistic_time;
        TextView mLogistic_process;
    }
}
